#pragma once

#include <string>
#include "..\common\common.h"
#include "params.h"

using namespace std;
using namespace AI9;

namespace ArmyStateNS {

class BaseState 
{
public:
	BaseState(AI9::GeneralType name) : m_name(name) { } 
	virtual string get_type() = 0;
	virtual void execute() = 0;

	static void enter_state(GeneralType name, BaseState *state);
protected:
	AI9::GeneralType m_name;
};

class IdleState : public BaseState
{
public:
	IdleState(AI9::GeneralType name) : BaseState(name) {  } 
	virtual string get_type() { return "IdleState"; } 
	virtual void execute();
};

class InitState : public BaseState
{
public:
	InitState(AI9::GeneralType name) : BaseState(name) {  } 
	virtual string get_type() { return "InitState"; } 
	virtual void execute();

public:
	static bool initialized;
};

class OccupyingState : public BaseState
{
public:
	static std::map<GeneralType, Position> target_map;
	static bool find_target(GeneralType general, Position &target);
	static bool city_assigned(Position p);
	static void assign(GeneralType general, Position p);
	static void remove(GeneralType general);

};

class FastOccupyingState : public BaseState
{
public:
	FastOccupyingState(AI9::GeneralType name) : BaseState(name) 
	{
		 
		m_target = Position(-1, -1);
	}
 
	FastOccupyingState(AI9::GeneralType name, Position target) : BaseState(name) 
	{
		 
		m_target = target;
	}
 
	virtual string get_type() { return "FastOccupyingState"; } 
	virtual void execute();

	Position m_target;
};

class ManageState : public BaseState
{
public:
	ManageState(AI9::GeneralType name) : BaseState(name) {   m_target = Position(-1, -1); } 
	ManageState(AI9::GeneralType name, Position target) : BaseState(name) {  m_target = target; } 
	virtual string get_type() { return "ManageState"; } 
	virtual void execute();

public:
	Position m_target;
};

class BattleState: public BaseState
{
public:
	BattleState(AI9::GeneralType name) : BaseState(name) {   } 
	virtual string get_type() { return "BattleState"; } 
	virtual void execute();
};

class DefensiveBattleState: public BaseState
{
public:
	DefensiveBattleState(AI9::GeneralType name, Position target) : BaseState(name) {  m_target = target; } 
	virtual string get_type() { return "DefensiveBattleState"; } 
	virtual void execute();

public:
	Position m_target;
};



}